﻿<%@ Page Language="C#" AutoEventWireup="false" Inherits="Web.BasePage"%>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="MAF.Common" %>
<%@ Import Namespace="Domain.Entities" %>
<%@ Import Namespace="Web" %>
<%@ Import Namespace="Web.UI" %>
<%@ Import Namespace="Web.Controller" %>

<% 
    string catName = ModuleTranslate(Module);
    string parentId = Request.QueryString["ParentId"];
    if( !string.IsNullOrEmpty(parentId) )
    {
        CategoryInfo cat = Business.BusinessFactory.CreateCategory(Module).Show(new Guid(parentId));
        if (null != cat)
            catName = cat.Name;
    }
%>

<div id="nutrition" class="box">
    <b class="rc-tp"><b></b></b>
    <span class="shadow"></span>
    <div class="hd">
        <span class="icon"></span>
        <h2><%=catName %></h2>
    </div>
    <div class="bd clearfix">

<!-- contents -->
        <% if( SecurityUI.IsMaintainMode(null) ){ %>
            <a href="Part.aspx?Module=<%=Module %>&Handler=Product&Action=New" class="btn-add-product">添加产品</a>
        <%} %>

        <ul class="clearfix">
        <% 
            PageInfo page;
            ProductHandler h = new ProductHandler();
            IList<ProductInfo> list = h.Index(out page);

            foreach (ProductInfo info in list)
            {
        %>
            <li>
                <div class="pic">
                    <a href="Default.aspx?Module=<%=Module %>&Handler=Product&Action=Show&Id=<%=info.Id %>"><img src="<%=WebConf.ImagesRootPath %>/<%=this.Module %>/<%=info.FilePath %>" /></a>
                </div>
                <span class="price"><%=info.Price %></span>
                <div class="summary">
                    <a href="Default.aspx?Module=<%=Module %>&Handler=Product&Action=Show&Id=<%=info.Id %>"><%= info.Name %></a><br />
                    <em>适宜群：<%=info.ApplyTo %></em>
                </div>
                <div>
                    <%--<input type="checkbox" name="Id" value="<%=info.Id %>" />--%>
                    <% if( SecurityUI.IsMaintainMode(null) ){ %>
                    <a href="Part.aspx?Module=<%=Module %>&Handler=Product&Action=Edit&Id=<%=info.Id %>" class="btn-update-product">编辑</a>
                    <a href="Part.aspx?Module=<%=Module %>&Handler=Product&Action=Delete&Id=<%=info.Id %>" class="btn-delete-product">删除</a>
                    <%} %>
                </div>
            </li>
        <% 
            }
        %>
        </ul>

        <div class="green-black ">
        <%
            // 分页导航条
            if (null != page)
            {
                WebPageNavigator nav = new WebPageNavigator(page, Request.QueryString);
                Response.Write(nav.ToString());
            }
        %>
        </div>
<!-- contents -->

    </div>
</div>